home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 September / CHIP Eylül 1998.iso / Slackwar / docs / mini / Bzip2 < prev    next >
Text File  |  1997-03-16  |  13KB  |  361 lines

  1.   Bzip2 Howto
  2.   David Fetter, dfetter@best.com <mailto:dfetter@best.com>
  3.   v1.6 Tue Mar 10 17:48:42 PST 1998
  4.  
  5.   This document tells how to use the new bzip2 compression program.  The
  6.   original sgml is here
  7.   <http://www.best.com/~dfetter/Bzip2-HOWTO/Bzip2-HOWTO.sgml>.
  8.  
  9.   1.  Introduction
  10.  
  11.   Bzip2 is a groovy new algorithm for compressing data.  It generally
  12.   makes files that are 60-70% of the size of their gzip'd counterparts.
  13.  
  14.   This document will take you through a few common applications for
  15.   bzip2.
  16.  
  17.   French speakers may wish to refer to Arnaud Launay's French documents.
  18.   The web version is here
  19.   <http://www.freenix.fr/linux/HOWTO/mini/Bzip2.html>, and you can use
  20.   ftp here <ftp://ftp.lip6.fr/pub/linux/french/docs/HOWTO/mini/Bzip2.gz>
  21.   Arnaud can be contacted by electronic mail at this address
  22.   <mailto:zoro@mygale.org>
  23.  
  24.   Japanese speakers may wish to refer to Tetsu Isaji's Japanese
  25.   documents here <http://jf.gee.kyoto-u.ac.jp/JF/JF.html>.  Isaji can be
  26.   reached at his home page <http://www2s.biglobe.ne.jp/~kaien/>, or by
  27.   electronic mail at this address. <mailto:isaji@mxu.meshnet.or.jp>
  28.  
  29.   1.1.  Revision History
  30.  
  31.   1.1.1.  v1.6 Added TenThumbs' Netscape enabler.
  32.  
  33.   Also changed lesspipe.sh per his sugestion.  It should work better
  34.   now.
  35.  
  36.   1.1.2.  v1.5 Added Arnaud Launay's French translation, and his wu-ftpd
  37.   file.
  38.  
  39.   1.1.3.  v1.4 Added Tetsu Isaji's Japanese translation.
  40.  
  41.   1.1.4.  v1.3 Added Ulrik Dickow's .emacs for 19.30 and higher.
  42.  
  43.   (Also corrected jka-compr.el patch for emacs per his suggestion. Oops!
  44.   Bzip2's doesn't yet(?) have an "append" flag.)
  45.  
  46.   1.1.5.  v1.2  Changed patch for emacs so it automagically recognizes
  47.  
  48.   1.1.6.  v1.1  Added patch for emacs.
  49.  
  50.   1.1.7.  v1.0  Round 1.
  51.  
  52.   2.  Getting bzip2
  53.  
  54.   Bzip2's home page is at The UK home site
  55.   <http://www.muraroa.demon.co.uk/>.  The United States mirror site is
  56.   here <http://www.digistar.com/bzip2/index.html>.  You can also find it
  57.   on Red Hat's ftp site here <ftp://ftp.redhat.com/pub/contrib>.
  58.  
  59.   2.1.  Getting bzip2 precompiled binaries
  60.  
  61.   See the home sites.  Red Hat's intel binary is here
  62.   <ftp://ftp.redhat.com/pub/contrib/i386/bzip2-0.1pl2-1.i386.rpm>.
  63.   Debian's is here <ftp://ftp.debian.org/debian/hamm/hamm/binary-
  64.   i386/utils/bzip2_0.1pl2-4.deb>, and Slackware's is here
  65.   <http://www.cdrom.com/pub/linux/slackware-3.4/slakware/a9/bzip2.tgz>.
  66.   You can also get these in the analogous places at the various mirror
  67.   sites.
  68.  
  69.   2.2.  Getting bzip2 sources
  70.  
  71.   They come from the Official sites (see ``Getting Bzip2'' for where, or
  72.   Red Hat has it here
  73.   <ftp://ftp.redhat.com/pub/contrib/SRPMS/bzip2-0.1pl2-1.src.rpm>).
  74.  
  75.   2.3.  Compiling bzip2 for your machine
  76.  
  77.   If you have gcc 2.7.2.3, change the line that reads
  78.  
  79.        CFLAGS = -O3 -fomit-frame-pointer -funroll-loops
  80.  
  81.   to
  82.  
  83.        CFLAGS = -fomit-frame-pointer -funroll-loops
  84.  
  85.   that is, take out the -O3 part.  After that, just make it and install
  86.   it per the README.
  87.  
  88.   3.  Using bzip2 by itself
  89.  
  90.   Read the Fine Manual Page :)
  91.  
  92.   4.  Using bzip2 with tar
  93.  
  94.   Basically, there are two ways to use this, namely
  95.  
  96.   4.1.  Easier to set up:
  97.  
  98.   This method requires no setup at all.  To un-tar the bzip2'd tar
  99.   archive, foo.tar.bz in the current directory, do
  100.  
  101.        /path/to/bzip2 -cd foo.tar.bz2 | tar xf -
  102.  
  103.   This works, but can be a PITA to type often.
  104.  
  105.   4.2.  Easier to use:
  106.  
  107.   Apply the following patch to gnu tar 1.12, compile it, and install it,
  108.   and you're good to go.  Make sure that both tar and bzip2 are in your
  109.   $PATH by "which tar" and "which bzip2.  To use it, just do
  110.  
  111.         tar xyf foo.tar.bz2
  112.  
  113.   to decompress the file.
  114.  
  115.   To make a new archive, it's similar:
  116.  
  117.         tar cyf foo.tar.bz2 file1 file2 file3...directory1 directory2...
  118.  
  119.   And here's the patch :)
  120.  
  121.   *** tar.c.orig  Sat Apr 26 05:09:49 1997
  122.   --- tar.c       Feb  2 00:50:47 1998
  123.   ***************
  124.   *** 16,21 ****
  125.   --- 16,24 ----
  126.        with this program; if not, write to the Free Software Foundation, Inc.,
  127.        59 Place - Suite 330, Boston, MA 02111-1307, USA.  */
  128.  
  129.   + /* Feb 2 98: patched by David Fetter to use bzip2 as a
  130.   +              filter (option -y) */
  131.   +
  132.     #include "system.h"
  133.  
  134.     #include <getopt.h>
  135.   ***************
  136.   *** 196,201 ****
  137.   --- 199,206 ----
  138.       {"block-number", no_argument, NULL, 'R'},
  139.       {"block-size", required_argument, NULL, OBSOLETE_BLOCKING_FACTOR},
  140.       {"blocking-factor", required_argument, NULL, 'b'},
  141.   +   {"bzip2", required_argument, NULL, 'y'},
  142.   +   {"bunzip2", required_argument, NULL, 'y'},
  143.       {"catenate", no_argument, NULL, 'A'},
  144.       {"checkpoint", no_argument, &checkpoint_option, 1},
  145.       {"compare", no_argument, NULL, 'd'},
  146.   ***************
  147.   *** 372,377 ****
  148.   --- 377,383 ----
  149.                   PATTERN                at list/extract time, a globbing PATTERN\n\
  150.       -o, --old-archive, --portability   write a V7 format archive\n\
  151.           --posix                        write a POSIX conformant archive\n\
  152.   +   -y, --bzip2, --bunzip2             filter the archive through bzip2\n\
  153.       -z, --gzip, --ungzip               filter the archive through gzip\n\
  154.       -Z, --compress, --uncompress       filter the archive through compress\n\
  155.           --use-compress-program=PROG    filter through PROG (must accept -d)\n"),
  156.   ***************
  157.   *** 448,454 ****
  158.        Y  per-block gzip compression */
  159.  
  160.     #define OPTION_STRING \
  161.   !   "-01234567ABC:F:GK:L:MN:OPRST:UV:WX:Zb:cdf:g:hiklmoprstuvwxz"
  162.  
  163.     static void
  164.     set_subcommand_option (enum subcommand subcommand)
  165.   --- 454,460 ----
  166.        Y  per-block gzip compression */
  167.  
  168.     #define OPTION_STRING \
  169.   !   "-01234567ABC:F:GK:L:MN:OPRST:UV:WX:Zb:cdf:g:hiklmoprstuvwxyz"
  170.  
  171.     static void
  172.     set_subcommand_option (enum subcommand subcommand)
  173.   ***************
  174.   *** 805,810 ****
  175.   --- 811,820 ----
  176.           case 'X':
  177.           exclude_option = 1;
  178.           add_exclude_file (optarg);
  179.   +       break;
  180.   +
  181.   +       case 'y':
  182.   +       set_use_compress_program_option ("bzip2");
  183.           break;
  184.  
  185.           case 'z':
  186.  
  187.   5.  Using bzip2 with less
  188.  
  189.   To uncompress bzip2'd files on the fly, i.e. to be able to use "less"
  190.   on them without first bunzip2'ing them, you can make a lesspipe.sh
  191.   (man less) like this:
  192.  
  193.   #!/bin/sh
  194.   # This is a preprocessor for 'less'.  It is used when this environment
  195.   # variable is set:   LESSOPEN="|lesspipe.sh %s"
  196.  
  197.     case "$1" in
  198.     *.tar) tar tvvf $1 2>/dev/null ;; # View contents of various tar'd files
  199.     *.tgz) tar tzvvf $1 2>/dev/null ;;
  200.   # This one work for the unmodified version of tar:
  201.     *.tar.bz2) bzip2 -cd $1 $1 2>/dev/null | tar tzvvf - ;;
  202.   #This one works with the patched version of tar:
  203.   # *.tar.bz2) tyvvf $1 2>/dev/null ;;
  204.     *.tar.gz) tar tzvvf $1 2>/dev/null ;;
  205.     *.tar.Z) tar tzvvf $1 2>/dev/null ;;
  206.     *.tar.z) tar tzvvf $1 2>/dev/null ;;
  207.     *.bz2) bzip2 -dc $1  2>/dev/null ;; # View compressed files correctly
  208.     *.Z) gzip -dc $1  2>/dev/null ;;
  209.     *.z) gzip -dc $1  2>/dev/null ;;
  210.     *.gz) gzip -dc $1  2>/dev/null ;;
  211.     *.zip) unzip -l $1 2>/dev/null ;;
  212.     *.1|*.2|*.3|*.4|*.5|*.6|*.7|*.8|*.9|*.n|*.man) FILE=`file -L $1` ; # groff src
  213.       FILE=`echo $FILE | cut -d ' ' -f 2`
  214.       if [ "$FILE" = "troff" ]; then
  215.         groff -s -p -t -e -Tascii -mandoc $1
  216.       fi ;;
  217.     *) cat $1 2>/dev/null ;;
  218.   #  *) FILE=`file -L $1` ; # Check to see if binary, if so -- view with 'strings'
  219.   #    FILE1=`echo $FILE | cut -d ' ' -f 2`
  220.   #    FILE2=`echo $FILE | cut -d ' ' -f 3`
  221.   #    if [ "$FILE1" = "Linux/i386" -o "$FILE2" = "Linux/i386" \
  222.   #         -o "$FILE1" = "ELF" -o "$FILE2" = "ELF" ]; then
  223.   #      strings $1
  224.   #    fi ;;
  225.     esac
  226.  
  227.   6.  Using bzip2 with emacs
  228.  
  229.   6.1.  Changing emacs for everyone:
  230.  
  231.   I've written the following patch to jka-compr.el which adds bzip2 to
  232.   auto-compression-mode.
  233.  
  234.   Disclaimer: I have only tested this with emacs-20.2, but have no
  235.   reason to believe that a similar approach won't work with other
  236.   versions.
  237.  
  238.   To use it,
  239.  
  240.   1. Go to the emacs-20.2/lisp source directory (wherever you untarred
  241.      it)
  242.  
  243.   2. Put the patch below in a file called jka-compr.el.diff (it should
  244.      be alone in that file ;).
  245.  
  246.   3. Do
  247.  
  248.    patch < jka-compr.el.diff
  249.  
  250.   4. Start emacs, and do
  251.  
  252.         M-x byte-compile-file jka-compr.el
  253.  
  254.   5. Leave emacs.
  255.  
  256.   6. Move your original jka-compr.elc to a safe place in case of bugs.
  257.  
  258.   7. Replace it with the new jka-compr.elc.
  259.  
  260.   8. Have fun!
  261.  
  262.      --- jka-compr.el        Sat Jul 26 17:02:39 1997
  263.      +++ jka-compr.el.new    Thu Feb  5 17:44:35 1998
  264.      @@ -44,7 +44,7 @@
  265.       ;; The variable, jka-compr-compression-info-list can be used to
  266.       ;; customize jka-compr to work with other compression programs.
  267.       ;; The default value of this variable allows jka-compr to work with
  268.      -;; Unix compress and gzip.
  269.      +;; Unix compress and gzip.  David Fetter added bzip2 support :)
  270.       ;;
  271.       ;; If you are concerned about the stderr output of gzip and other
  272.       ;; compression/decompression programs showing up in your buffers, you
  273.      @@ -121,7 +121,9 @@
  274.  
  275.       ;;; I have this defined so that .Z files are assumed to be in unix
  276.      -;;; compress format; and .gz files, in gzip format.
  277.      +;;; compress format; and .gz files, in gzip format, and .bz2 files,
  278.      +;;; in the snappy new bzip2 format from http://www.muraroa.demon.co.uk.
  279.      +;;; Keep up the good work, people!
  280.       (defcustom jka-compr-compression-info-list
  281.         ;;[regexp
  282.         ;; compr-message  compr-prog  compr-args
  283.      @@ -131,6 +133,10 @@
  284.            "compressing"    "compress"     ("-c")
  285.            "uncompressing"  "uncompress"   ("-c")
  286.            nil t]
  287.      +    ["\\.bz2\\'"
  288.      +     "bzip2ing"        "bzip2"         ("")
  289.      +     "bunzip2ing"      "bzip2"         ("-d")
  290.      +     nil t]
  291.           ["\\.tgz\\'"
  292.            "zipping"        "gzip"         ("-c" "-q")
  293.            "unzipping"      "gzip"         ("-c" "-q" "-d")
  294.  
  295.   6.2.  Changing emacs for one person:
  296.  
  297.   Thanks for this one go to Ulrik Dickow, ukd@kampsax.dk
  298.   <mailto:ukd@kampsax.dk>, Systems Programmer at Kampsax Technology:
  299.  
  300.   To make it so you can use bzip2 automatically when you aren't the
  301.   sysadmin, just add the following to your .emacs file.
  302.   ;; Automatic (un)compression on loading/saving files (gzip(1) and similar)
  303.   ;; We start it in the off state, so that bzip2(1) support can be added.
  304.   ;; Code thrown together by Ulrik Dickow for ~/.emacs with Emacs 19.34.
  305.   ;; Should work with many older and newer Emacsen too.  No warranty though.
  306.   ;;
  307.   (if (fboundp 'auto-compression-mode) ; Emacs 19.30+
  308.       (auto-compression-mode 0)
  309.     (require 'jka-compr)
  310.     (toggle-auto-compression 0))
  311.   ;; Now add bzip2 support and turn auto compression back on.
  312.   (add-to-list 'jka-compr-compression-info-list
  313.                ["\\.bz2\\(~\\|\\.~[0-9]+~\\)?\\'"
  314.                 "zipping"        "bzip2"         ()
  315.                 "unzipping"      "bzip2"         ("-d")
  316.                 nil t])
  317.   (toggle-auto-compression 1 t)
  318.  
  319.   7.  Using bzip2 with wu-ftpd
  320.  
  321.   Thanks to Arnaud Launay for this bandwidth saver.  The following
  322.   should go in /etc/ftpconversions to do on-the-fly compressions and
  323.   decompressions with bzip2. Make sure that the paths (like
  324.   /bin/compress) are right.
  325.  
  326.    :.Z:  :  :/bin/compress -d -c %s:T_REG|T_ASCII:O_UNCOMPRESS:UNCOMPRESS
  327.    :   : :.Z:/bin/compress -c %s:T_REG:O_COMPRESS:COMPRESS
  328.    :.gz: :  :/bin/gzip -cd %s:T_REG|T_ASCII:O_UNCOMPRESS:GUNZIP
  329.    :   : :.gz:/bin/gzip -9 -c %s:T_REG:O_COMPRESS:GZIP
  330.    :.bz2: :  :/bin/bzip2 -cd %s:T_REG|T_ASCII:O_UNCOMPRESS:BUNZIP2
  331.    :   : :.bz2:/bin/bzip2 -9 -c %s:T_REG:O_COMPRESS:BZIP2
  332.    :   : :.tar:/bin/tar -c -f - %s:T_REG|T_DIR:O_TAR:TAR
  333.    :   : :.tar.Z:/bin/tar -c -Z -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+COMPRESS
  334.    :   : :.tar.gz:/bin/tar -c -z -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+GZIP
  335.    :   : :.tar.bz2:/bin/tar -c -I -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+BZIP2
  336.  
  337.   8.  Using bzip2 with Netscape under XWindows
  338.  
  339.   tenthumbs@cybernex.net says:
  340.  
  341.        I also found a way to get Linux Netscape to use bzip2 for Content-
  342.        Encoding just as it uses gzip. Add this to $HOME/.Xdefaults or
  343.        $HOME/.Xresources
  344.  
  345.        I use the -s option because I would rather trade some decompressing
  346.        speed for RAM usage. You can leave the option out if you want to.
  347.  
  348.   Netscape*encodingFilters:      \
  349.           x-compress :  : .Z     : uncompress -c  \n\
  350.           compress   :  : .Z     : uncompress -c  \n\
  351.           x-gzip     :  : .z,.gz : gzip -cdq      \n\
  352.           gzip       :  : .z,.gz : gzip -cdq      \n\
  353.           x-bzip2    :  : .bz2   : bzip2 -ds \n
  354.  
  355.   9.  Using bzip2 with xv
  356.  
  357.   I'm working on a patch which should let xv auto-decompress bzip2'd
  358.   files the way it can do compress'd and gzip'd ones. Anybody want to
  359.   help out?
  360.  
  361.